package edu.poly.game.battleship;

/**
 * Aircraft type enumeration
 * we define as seperate because of IBM rational architect cannot define
 * inner class.
 * 
 * we define it's ordinal explicitly, since java enum type starts at 0
 * 
 * @author kevint
 */
public enum BattleShipType {
	AIRCRAFTCARRIER(1, "Aircraft Carrier"),
	DESTROYER(2, "Destroyer"),
	PATROLBOAT(3, "Patrol Boat");
	
	private String name;
	private int ordinal;
	
	/**
	 * enum internal constructor, this enum should not be constructed
	 * @param ordinal
	 * @param name
	 */
	private BattleShipType(final int ordinal, final String name) {
		this.ordinal = ordinal;
		this.name = name;
	}

	/**
	 * get ship name
	 * @return ship name
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * ship ordering
	 * @return ship ordering
	 */
	public int getOrdinal() {
		return this.ordinal;
	}
	
	/**
	 * statis method for getting battle ship type based on its ordinal
	 * @param ordinal
	 * @return
	 */
	public static BattleShipType getBattleShipType(final int ordinal) {
		/**
		 * static method for getting battle ship type based on its ordinal
		 */
		switch(ordinal) {
			case 1: 
				return AIRCRAFTCARRIER;
			case 2: 
				return DESTROYER;
			case 3: 
				return PATROLBOAT;
			default: 
				return null;
		}
	}
}
